package com.learn.netty.nio;

import lombok.extern.slf4j.Slf4j;

import java.nio.IntBuffer;

/**
 * @author zhongshitao
 * @date 2020/10/12 11:04 上午
 */
@Slf4j
public class BasicBuffer {


    public static void main(String[] args) {
        // 分配空间
        IntBuffer buffer = IntBuffer.allocate(5);
        for (int i = 0;i<buffer.capacity();i++) {
            buffer.put(i*2);
        }
        // 翻转
        buffer.flip();
        while (buffer.hasRemaining()) {
            System.out.println(buffer.get());
        }

    }


}
